package com.zhida.chatservice.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.zhida.chatservice.service.OfflineService;
import com.zhida.common.entity.Result;
import com.zhida.common.utils.TokenProcessor;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Create by zhh 2024/7/16 7:46
 */
@RestController
@RequestMapping("/ws")
public class OfflineController {

    @Resource
    final OfflineService offlineService;

    public OfflineController(OfflineService offlineService) {
        this.offlineService = offlineService;
    }

    @RequestMapping("/getOfflineMsg")
    public Result<?> getOfflineMsg(HttpServletRequest request) throws JsonProcessingException {
        return offlineService.getOfflineMsg(TokenProcessor.getUsername(request));
    }
}
